package J.算法.排序;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class _0330 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        while ((str=br.readLine())!= null){
            String[] strs = str.split(",");
            int[] nums = new int[strs.length];
            for (int i = 0; i < nums.length; i++) {
                nums[i] = Integer.valueOf(strs[i]);
            }
            //shellSort(nums);
            mergeSort(nums,0,nums.length-1);
            for (int n:nums){
                System.out.println(n);
            }
        }
    }

    public static void Bubble(int[] nums){

        int temp = 0;
        boolean change = false;
        for (int i = 0; i < nums.length-1; i++) {
            for (int j = 0; j < nums.length-i-1; j++) {
                if (nums[j] < nums[j+1]){
                    change = true;
                    temp = nums[j];
                    nums[j] = nums[j+1] ;
                    nums[j+1] = temp;
                }

                if (!change){
                    break;
                }

            }
        }
    }

    public static void select(int[] nums){

        for (int i = 0; i < nums.length-1; i++) {
            int min = nums[i];
           // int temp = min;
            for (int j=i+1;j< nums.length;j++){
                if (nums[j]<min){
                    nums[i] = nums[j];
                    nums[j] = min;
                }

            }

        }
    }

    /**注意这块 i从1开始 就从i开始
     * @param nums
     */
    public static void insertSort(int[] nums){

        for (int i = 1; i < nums.length; i++) {

            for (int j= i;j< nums.length;j++){
                int searchIndex = j-1;
                int insertVal  = nums[j];

                while (searchIndex>= 0 && insertVal < nums[searchIndex]){
                    nums[searchIndex+1] = nums[searchIndex];
                    searchIndex--;
                }
                nums[searchIndex+1] = insertVal;
            }
        }
    }

    public static void shellSort(int[] nums){

        for (int gap =  nums.length/2; gap > 0; gap /=2) {
            for (int i = gap; i < nums.length; i+=gap) {
                int searchIndex = i-gap;
                int insertVal = nums[i];

                while (searchIndex>= 0 && insertVal< nums[searchIndex]){
                    nums[searchIndex+gap] = nums[searchIndex];
                    searchIndex -= gap;

                }
                nums[searchIndex+gap] = insertVal;

            }
        }


    }

    public static void quick(int[] nums,int start,int end){

        if (start<end){
            int base = nums[start];
            int low = start;
            int high = end;

            while (low<high){

                while (low < high && nums[high]> base){
                    high--;
                }
                nums[low] = nums[high];

                while (low < high && nums[low] < base){
                    low++;
                }
                nums[high] = nums[low];
            }
            nums[low] = base;

            quick(nums,start,low);
            quick(nums,low+1,end);
        }


    }

    public static void  mergeSort(int[] nums,int start,int end){
        if (start<end){
            int mid = (start+end)/2;

            mergeSort(nums,start,mid);
            mergeSort(nums,mid+1,end);

            merge(nums,start,mid,end);
        }



    }
    public static  void  merge(int[] nums,int left,int mid ,int right){
        int i = left;
        int j = mid+1;
        int[] temp = new int[right-left+1];
        int index =0;

        while (i<=mid && j<= right){
            if (nums[i]<nums[j]){
                temp[index++] = nums[i];
                i++;
            }else {
                temp[index++] = nums[j];
                j++;
            }
        }

        while (i<= mid){
            temp[index++] = nums[i];
            i++;
        }
        while (j<=right){
            temp[index++] = nums[j];
            j++;
        }

        int from = left;
        for (int n:temp){
            nums[from++] = n;
        }

    }



}
